﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

using DM_Article.Bll;
using DM_Article.Model;

public partial class admin_admin_server : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["username"] == null)
            {
                Response.Write("<script language='javascript'>alert('非法操作，请先登录！');location.href = 'admin_login.aspx';</script>");
            }
            else
            {
                getarticle();
            }
        }
    }

    private void getarticle()
    {
        using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()))
        {
            this.GV_article.DataSource = articlebll.getArticleByHitsTable(cn, 5).DefaultView;
            this.GV_article.DataBind();
        }
    }

    protected void GV_article_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()))
            {
                e.Row.Cells[3].Text = bigclassbll.getBigclassDetail(cn, e.Row.Cells[3].Text).bigclassname;
                e.Row.Cells[4].Text = smallclassbll.getSmallclassDetail(cn, e.Row.Cells[4].Text).smallclassname;
            }
        }
    }
}
